home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_07_08
/
v7n8092a.txt
< prev
next >
Wrap
Text File
|
1988-12-19
|
923b
|
30 lines
/* include file for hash searching */
class hashtable
{ // private:
typedef struct entry { char *key, *data; } ENTRY;
unsigned prime(unsigned size); // generate prime number
int hash(char *str); // hash function
int hcreate(unsigned nel); // create hash table
static ENTRY *hash_table; // pointer to hash table
static unsigned num_elem; // max num table elements
static unsigned count; // current table entry count
public:
typedef enum { fIND, ENTER, DELETE } ACTION;
hashtable(unsigned size) // constructor
{
hcreate(size);
}
void hdestroy();
// search for an item
ENTRY *hsearch(ENTRY item, ACTION action);
unsigned hcount(); // num items in table
unsigned hsize(); // hash table size
int hwrite(); // write hash table
int hread(); // read hash table
~hashtable() { hdestroy(); } // destructor
};